<?php
class Recommend_listWidget extends BaseWidget{
	public function get_data(){
		$type = $this->config['type'];
		$model = $this->config['model'];
		$mod = new RecommendModel();
		$recommend = $mod->get_by_attrs(array('site_id'=>SITE_ID, 'type'=>$type, 'model'=>$model));
		$recommend['items'] = SortHelper::sortByCol($recommend['items'], 'rank');
		$picture_list = array();
		$text_list = array();
		$i = 0;
		foreach ($recommend['items'] as $id=>$w){
			if($i<8){
				//添加到图片
				if(utf8_strlen($w['desc'])>30){
					$w['desc'] = cut_str($w['desc'], 28);
				}
				$picture_list[] = $w;
			}elseif($i<16){
				$text_list[] = $w;
			}else{
				break;
			}
			++$i;
		}
		return array(
			'picture_list' => $picture_list,
			'text_list' => $text_list,
			'recommend' => $recommend
		);
	}
}

?>